//加载mysql模块
const { rejects } = require('assert')
const mysql = require('mysql')
const { resolve } = require('path')
const pool = mysql.createPool({
    connectionLimit:20,
    host:'localhost',
    user:'root',
    password:'',
    database:'bmdstudios'
})
//为pool新增一个方法，同步执行的方法
pool.querySync = (sql,params) => {
    return new Promise((resolve,rejects) => {
        pool.query(sql,params,(error,result) => {
            if(error){
                rejects(error)
            }else{
                resolve(result)
            }
        })
    })
}

module.exports = pool